﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Services;
using System.Collections;

namespace Catering.Catering_Page.system
{
    public partial class AreaRules : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.LoadRep();
            }
        }

        //加载Rep
        public void LoadRep()
        {
            DataTable dt_Area = new Catering_Rules.AreaRules().GetAllList().Tables[0];
            this.Rep_OperationArea.DataSource = dt_Area;
            this.Rep_OperationArea.DataBind();
        }

        public string GetAreaNameByID(string StrID)
        {
            int id = 0;
            Int32.TryParse(StrID, out id);
            if (id > 0)
            {
                Catering_Model.Area md = new Catering_Rules.Area().GetModel(id);
                if (md != null) return md.Name;
            }
            return "";
        }

        ////获取
        //[WebMethod]
        //public static ArrayList Get(string ARID)
        //{
        //    ArrayList al = new ArrayList();
        //    Catering_Model.AreaRules md = new Catering_Rules.AreaRules().GetModel(Convert.ToInt32(ARID));
        //    al.Add(md.ARName);
        //    al.Add(md.AreaID);
        //    al.Add(md.RawIDs);
        //    return al;
        //}

        ////添加
        //[WebMethod]
        //public static string Add(string ARName, string AreaID, string RawIDs)
        //{
        //    Catering_Model.AreaRules md = new Catering_Model.AreaRules();
        //    md.ARName = ARName;
        //    md.AreaID = Convert.ToInt32(AreaID);
        //    md.RawIDs = RawIDs;
        //    new Catering_Rules.AreaRules().Add(md);
        //    return "OK";
        //}

        ////修改
        //[WebMethod]
        //public static string Edit(string ARID, string ARName, string AreaID, string RawIDs)
        //{
        //    Catering_Model.AreaRules md = new Catering_Model.AreaRules();
        //    md.ARID = Convert.ToInt32(ARID);
        //    md.ARName = ARName;
        //    md.AreaID = Convert.ToInt32(AreaID);
        //    md.RawIDs = RawIDs;
        //    new Catering_Rules.AreaRules().Update(md);
        //    return "OK";
        //}

        //删除
        protected void Rep_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "del")
            {
                int delID = Convert.ToInt32(e.CommandArgument);
                if (new Catering_Rules.AreaRules().Delete(delID))
                {
                    this.LoadRep();
                }
            }
        }
    }
}